package models

import (
	"gorm.io/gorm"
	"hitme/go-api/modules/db"
)

var OrderModel = new(Order)

// 订单表
type Order struct {
	db.CommonModel
	Uid             uint64      `gorm:"type:int(11);default:0;NOT NULL;comment:用户ID" json:"uid"`
	OrderSn         string      `gorm:"type:varchar(100);default:'';NOT NULL;comment:单号" json:"order_sn"`
	Price           uint64      `gorm:"type:int(11);not null;default:0;comment:价格" json:"price"`
	Quantity        uint64      `gorm:"type:int(11);default:1;NOT NULL;comment:数量" json:"quantity"`
	Amount          uint64      `gorm:"type:int(11);not null;default:0;comment:总价" json:"amount"`
	Status          int8        `gorm:"type:int(11);default:1;NOT NULL;comment:订单状态 1未支付 2支付中 3支付成功 4支付失败 5支付成功未获取到无水印证件照" json:"status"`
	SpecId          uint64      `gorm:"type:int(11);default:0;NOT NULL;comment:规格ID" json:"spec_id"`
	Title           string      `gorm:"type:varchar(50);default:'';NOT NULL;comment:规格标题" json:"title"`
	PayAt           db.JSONTime `gorm:"index;type:timestamp;comment:支付时间" json:"pay_at"`
	PhotoWmUrl      string      `gorm:"type:varchar(255);default:'';NOT NULL;comment:带水印照片地址" json:"photo_wm_url"`
	OriginPhotoName string      `gorm:"type:longtext;comment:原图片base64" json:"origin_photo_name"`
	PicId           string      `gorm:"type:varchar(20);default:'';NOT NULL;comment:pic id（请求api用）" json:"pic_id"`
	PhotoUrl        string      `gorm:"type:varchar(255);default:'';NOT NULL;comment:无水印照片地址" json:"photo_url"`
	FailReason      string      `gorm:"type:varchar(255);default:'';NOT NULL;comment:失败原因" json:"fail_reason"`
	Cloth           string      `gorm:"type:varchar(255);default:'';NOT NULL;comment:变装ID" json:"cloth"`
	Color           string      `gorm:"type:varchar(255);default:'';NOT NULL;comment:背景色" json:"color"`
	IsFair          int8        `gorm:"type:tinyint(4);default:0;NOT NULL;comment:是否美颜" json:"is_fair"`
}

func (m *Order) TableName() string {
	return "order"
}

func (m *Order) Model() *gorm.DB {
	return db.MysqlDB.Model(&m)
}